"""共享类型定义，用于避免循环导入"""
from enum import Enum
from typing import Optional, Dict, Any, List, Protocol, TypeVar, Generic


class ModelType(Enum):
    """模型类型枚举"""
    LOCAL = "local"
    CLOUD = "cloud"
    FALLBACK = "fallback"
    OLLAMA = "ollama"
    VLLM = "vllm"
    LLAMA_CPP = "llama_cpp"


class CloudLLMType(Enum):
    """云端LLM类型枚举"""
    OPENAI = "openai"
    TONGYI = "tongyi"
    ZHIPU = "zhipu"
    DOUBAO = "doubao"


class BaseModelClientProtocol(Protocol):
    """基础模型客户端协议"""
    
    def __init__(self, model_type: ModelType, config: Optional[Dict] = None):
        pass
    
    async def generate(self, prompt: str, contexts: Optional[List[str]] = None, **kwargs) -> str:
        pass
    
    async def batch_generate(self, prompts: List[str], **kwargs) -> List[str]:
        pass
    
    async def health_check(self) -> bool:
        pass


class CloudLLMClientProtocol(Protocol):
    """云端LLM客户端协议"""
    
    def __init__(self, cloud_type: CloudLLMType, config: Optional[Dict] = None):
        pass
    
    async def generate(self, prompt: str, contexts: Optional[List[str]] = None, **kwargs) -> str:
        pass
    
    @classmethod
    async def create_client(cls, cloud_type: str, config: Dict = None) -> 'CloudLLMClientProtocol':
        pass
